package edu.szu.huhanpeng.doodlingFight.controller.dataController.manageDone 
{
	import edu.szu.huhanpeng.doodlingFight.model.ChessGroupProxy;
	import edu.szu.huhanpeng.doodlingFight.model.ScoreProxy;
	import org.puremvc.as3.interfaces.ICommand;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.interfaces.INotifier;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	/**
	 * ...
	 * @author Huhanpeng
	 */
	public class CalculateScoreDc extends SimpleCommand implements ICommand, INotifier 
	{
		
		override public function execute(note:INotification):void 
		{
			var groupProxy:ChessGroupProxy = facade.retrieveProxy( ChessGroupProxy.NAME ) as ChessGroupProxy;
			var doneArr:Array = groupProxy.getDone();
			
			var count:int = 0;
			for (var i:int = 0; i < doneArr.length; i++) 
			{
				count += doneArr[i].length;
			}
			
			var scoreProxy:ScoreProxy = facade.retrieveProxy( ScoreProxy.NAME ) as ScoreProxy;
			scoreProxy.calculate( count );
			trace( scoreProxy.score )
		}
		
	}

}